#ifndef _CANIMATION_H
#define _CANIMATION_H

#include "windows.h"
#include "d3d9.h"
#include "d3dx9.h"

class CAnimation
{
public:
	//--------------------------------------------//
	//	Constructor and Destructor for this class //
	//--------------------------------------------//
	CAnimation();
	~CAnimation();

	//--------------------------------//
	//	Public methods for this class //
	//--------------------------------//
	void		CreateAnimation				( USHORT ID , ULONG FrameStartIndex , ULONG FrameEndIndex , ULONG FrameLoopIndex , float ActionSpeed );
	void		UpdateAnimation				( float deltaTime , RECT* scrRect , int width , int height , int NumFrameInRow );
	RECT		UpdateSourceRect			( int width , int height , int NumFrameInRow );

	USHORT		GetID						( );
	
	void		SetActionSpeed				( float NewSpeed );
	void		SetCurrentFrameIndex		( ULONG CurrentIndex );
	void		SetStartFrameIndex			( ULONG StartIndex );
	void		SetEndFrameIndex			( ULONG EndIndex );
	void		SetFrameLoopIndex			( ULONG LoopIndex );

	float		GetActionSpeed				( );
	ULONG		GetCurrentFrameIndex		( );
	ULONG		GetStartFrameIndex			( );
	ULONG		GetEndFrameIndex			( );
	ULONG		GetFrameLoopIndex			( );

	void		NextFrame					( );
	void		PrevFrame					( );
private:
	//-----------------------------------//
	//	Private variables for this class //
	//-----------------------------------//
	USHORT	m_UID;							//The unique ID for this animation;
	ULONG	m_nFrameStartIndex;				//The Frame start index of this animation
	ULONG	m_nFrameEndIndex;				//The Frame end index of this animation
	ULONG	m_nCurrFrameIndex;				//The Current frame index of this animation
	ULONG	m_nFrameLoopIndex;				//The Index of frame when the animation loop will start
	float 	m_fLocalTime;					//The local time of this animation
	float	m_fActionSpeed;					//The speed of this animation
											//		m_fLocalTime += deltaTime
											//		if(m_fLocalTime > m_fActionSpeed)
											//			we are going to update frame here
};

#endif